package cm.fw.exception;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.StreamingResolution;
import net.sourceforge.stripes.exception.DefaultExceptionHandler;

import org.apache.log4j.Logger;

public class Exceptionhandler
        extends DefaultExceptionHandler {

    static Logger logger = Logger.getLogger("test1");

    public Resolution handleGeneric(
            Exception exc,
            HttpServletRequest request,
            HttpServletResponse response)
            throws ServletException, IOException {
        
        if ("true".equals(request.getParameter("ajaxFlag"))) {
            
            logger.error("", exc.getCause());
            return new StreamingResolution("text", "false");
            
        } else {
            logger.error("", exc.fillInStackTrace());
            return new ForwardResolution("/jsp/exception/error.jsp");
        }

    }
}
